package com.yihaodian.index.meta.shard.impl;

import java.util.Collections;
import java.util.List;

import com.yihaodian.api.index.IndexDoc;
import com.yihaodian.cluster.ClusterState;
import com.yihaodian.index.meta.shard.ShardHandler;
import com.yihaodian.index.meta.shard.ShardId;

public class RuleBasedShardHandler implements ShardHandler {

	private List<ShardRule> rules;

	public List<ShardRule> getPolicies() {
		return rules;
	}

	public void setPolicies(List<ShardRule> rules) {
		this.rules = rules;
		Collections.sort(this.rules);
	}

	// public Map<String, List<Object>> shard(List<Object> objects) {
	// Map<String, List<Object>> map = new HashMap<String, List<Object>>();
	//
	// for(Object object : objects) {
	// String shardId = shard(object);
	// if(map.containsKey(shardId)) {
	// map.get(shardId).add(object);
	// } else {
	// List<Object> list = new ArrayList<Object>();
	// list.add(object);
	// map.put(shardId, list);
	// }
	// }
	//
	// return map;
	// }

	public ShardId shard(ClusterState cs, String indexName, IndexDoc object) {
	
		return null;
	}

}
